package com.gitee.kamismile.stone.rpc.api.engine;

import com.gitee.kamismile.stone.registry.api.IServiceDiscovery;
import com.gitee.kamismile.stone.rpc.api.invocation.support.StoneInvocation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class StoneListener {

    @Autowired
    private StoneAppEngine stoneAppEngine;

    @Autowired
    private IServiceDiscovery iServiceDiscovery;

    @EventListener
    public void getUserEvent(ApplicationReadyEvent event) {
        iServiceDiscovery.synProviderMeta();

        if(!stoneAppEngine.isServer()){
            return;
        }

        stoneAppEngine.start();
        iServiceDiscovery.register();
    }
}
